package com.xidian.GMS.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xidian.GMS.dto.Page;
import com.xidian.GMS.mapper.EmploymentConsultMapper;
import com.xidian.GMS.mapper.UserInfoMapper;
import com.xidian.GMS.service.UserInfoService;
import com.xidian.GMS.entity.Announcement;
import  com.xidian.GMS.entity.UserInfo;
import com.xidian.GMS.entity.UserInfoWithBLOBs;
@Service
public class UserInfoServiceImpl implements UserInfoService {

	@Autowired
	private UserInfoMapper userInfoMapper;
	@Override
	public UserInfoWithBLOBs Insert(UserInfoWithBLOBs userInfo) {
		   System.out.println("3333333333");
		   
		   	  int rows = userInfoMapper.insert(userInfo);
		      System.out.println("222222222");
				if( userInfo == null ||rows == 0){
					throw new RuntimeException("错误");
				}
		          return userInfo;
	}

	@Override
	public boolean delete(int uid) {
		   int x =  userInfoMapper.deleteByPrimaryKey(uid);
		  	  if (x == 1) {
		  	  	  return true;
			}
		          return false;
	}

	@Override
	public boolean update(UserInfoWithBLOBs userInfo) {
        int temp = userInfoMapper.updateByPrimaryKeySelective(userInfo);
		
    	  if (temp == 1) {
   	  	  return true;
 	}
           return false;
	}

	@Override
	public Page getUserInfo(int cur) {
		Page page = new Page(cur);
		
		int count = userInfoMapper.count();
		
		List<UserInfoWithBLOBs> accounts = userInfoMapper.findAll(page.getOffset(), page.getSize());
		
		page.setCount(count);
		page.setList(accounts);
		
		return page;
	}
	

}
